package code.gui;

import code.Grafo;
import java.awt.Dimension;
import java.awt.Toolkit;

public class FrmResultado extends javax.swing.JFrame {

    private static FrmResultado instance = null;

    public static FrmResultado getInstance() {
        if (instance == null) {
            instance = new FrmResultado();
        }
        return instance;
    }

    public void showResultado(Grafo grafo) {
        this.setVisible(true);
        taResultado.setText(grafo.getResultado());
    }

    private FrmResultado() {
        initComponents();
        this.setTitle("Resultado");        
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize();
        this.setLocation((screenSize.width - this.getWidth()) / 2, (screenSize.height - this.getHeight()) / 2);
        this.setVisible(true);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        taResultado = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        taResultado.setColumns(20);
        taResultado.setRows(5);
        taResultado.setTabSize(200);
        jScrollPane1.setViewportView(taResultado);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 728, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea taResultado;
    // End of variables declaration//GEN-END:variables

}
